<?php

// File : html_utilities.php

include_once("string_utilities.php");

// Returns text string for starting a HTML page.
function get_html_start($title, $style_sheet, $javascript = "", $charset = "utf-8")
{
  $return_value = "";
  
  $return_value = $return_value . "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"";
  $return_value = $return_value . "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
  
  $return_value = $return_value . "<html>\n";
  $return_value = $return_value . "<head>\n";
  
  // Character set
  $return_value = $return_value . "  <meta http-equiv=\"Content-Type\" content=\"text/html;charset=";
  $return_value = $return_value . $charset;
  $return_value = $return_value . "\" />\n";
  
  // Style sheet
  $return_value = $return_value . "  <link rel=\"stylesheet\" type=\"text/css\" href=";
  $return_value = $return_value . get_double_quoted_text($style_sheet);
  $return_value = $return_value . " />\n";
  
  // Title
  $return_value = $return_value . "  <title>" . $title . "</title>\n";
  
  // JavaScript
  if ($javascript != "")
  {
    $return_value = $return_value . "<script type = ";
    $return_value = $return_value . get_double_quoted_text("text/javascript");
    $return_value = $return_value . "src = ";
    $return_value = $return_value . get_double_quoted_text($javascript);
    $return_value = $return_value . "></script>";
  }
  
  $return_value = $return_value . "</head>\n";
  $return_value = $return_value . "<body>\n\n";
  
  return $return_value;
}

// Returns text string for wrapping up a HTML page.
function get_html_end()
{
  $return_value = "";
  
  $return_value = $return_value . "</body>\n";
  $return_value = $return_value . "</html>\n";
  
  return $return_value;
}

function get_href_text($url, $label)
{
    $return_value = "<a href=" . get_double_quoted_text($url) . ">" . $label . "</a>";
    return $return_value;  
}

function get_form_header_text($action, $method, $id, $class)
{
	$return_value = "<form action=";
	if ($action != "")
		$return_value = $return_value . get_double_quoted_text($action);
	else
		exit("get_form_header_text : Illegal function call!");

	if (($method == "post") || ($method == "get"))
		$return_value = $return_value . " method=" . get_double_quoted_text($method);
	else
		exit("get_form_header_text : Illegal function call!");
	
	if ($id != "")
		$return_value = $return_value . " id=" . get_double_quoted_text($id);

	if ($class != "")
		$return_value = $return_value . " class=" . get_double_quoted_text($class);
		
	$return_value = $return_value . ">";
	
	return $return_value;
}

?>